<template>
  <RouterView />
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user/index'
import { onMounted } from 'vue'

const router = useRouter()
const userStore = useUserStore()

/** 根据是否有用户信息处理路由跳转 */
const handleRouter = () => {
  const userInfo = userStore.userInfo
  if (userInfo.token) {
    // 不做处理，否则刷新页面路由会被修改
    // router.replace({ path: '/' })
  } else {
    router.replace({ path: '/login' })
  }
}

onMounted(() => {
  handleRouter()
})
</script>

<style scoped></style>
